home *** CD-ROM | disk | FTP | other *** search
- Path: lou.teclink.net!usenet
- From: rad@TECLink.net (rad)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: unsigned long addition question(GDS)
- Date: 12 Apr 1996 03:41:14 GMT
- Organization: TECLink Internet Services: info@TECLink.Net
- Message-ID: <1984.6675T1353T2973@TECLink.net>
- References: <1052.6674T364T2106@infi.net>
- NNTP-Posting-Host: tc1_15.teclink.net
- X-Newsreader: THOR 2.22 (Amiga;TCP/IP) *UNREGISTERED*
-
- On 10-Apr-96 04:27:07, DHopkins <dhopkins@infi.net> wrote:
- >I'm using Gamesmith with SAS/C and have run into a complete
- >blank in my math knowledge. GDS uses an 8-bit color table
- >eg. 0x00rrggbb. Usually, I just ignore this type of stuff
- >but now it's hit me square in the face.
-
- >I want to do a screen fade and figured that I'd use the
- >gs_SetRGB function to fade each color. the Commodore
- >version of SetRGB32 lets you enter a value for r, g, and b.
- >But gs_SetRGB only has 1 variable for the color, and it
- >has r,g,b embedded in it.(like I said, 0x00rrggbb). How
- >can I subtract from just r,g or b?
- >
- >I don't think I can do this...
- >
- >n=0x00rrggbb
- >n--
-
- correct, it won't work right for red & green.
-
- >but what about...
- >
- >n = 0x00rrggbb - 0x000001 (to subtract from b)
- >
- >n = 0x00rrggbb - 0x00010000 (to subtract from r)
-
- You could do this, but you must make sure that you don't underflow any of the
- fields. For example:
-
- n = 0x00000000 -0x00000100 gives you 0xffffff00... changing red & green.
-
- You would probably be better off using a union to break up you're number:
-
- union rgb_conv_T {
- long long_format;
- struct {
- char unused; /* MSB */
- char red;
- char green;
- char blue; /* LSB */
- } short_format;
- } convertor;
-
- Then you could do:
-
- convertor.long_format = /* get a color ... */
-
- convertor.short_format.red--;
- convertor.short_format.green--;
- convertor.short_format.blue--;
- /* or whatever you needed to do */
-
- /* save new color */ = convertor.long_format;
-
- This should work as long as you stick to the Amiga. ;)
-
-
- ---------------------------------------------------------------------------
- - Richard Deken EMail: (personal) rad@teclink.net -
- - VLSI Design Engineer (AuE) rad@aue.com -
- - Advanced Microelectronics PGP public key available -
- ---------------------------------------------------------------------------
-
-